<template>
  <div>
    <el-form-item label="对齐方式">
      <el-select
        v-model="localData.children.align"
        placeholder="对齐方式"
        clearable>
        <el-option
          label="居左"
          value="left" />
        <el-option
          label="居中"
          value="center" />
        <el-option
          label="居右"
          value="right" />
      </el-select>
    </el-form-item>
    <el-form-item
      label="头部对齐方式"
      label-width="110px">
      <el-select
        v-model="localData.children.headerAlign"
        placeholder="对齐方式"
        clearable>
        <el-option
          label="居左"
          value="left" />
        <el-option
          label="居中"
          value="center" />
        <el-option
          label="居右"
          value="right" />
      </el-select>
    </el-form-item>
    <el-form-item label="表单格式">
      <el-select
        v-model="localData.children.type"
        placeholder="表单格式"
        clearable>
        <el-option
          label="表格"
          value="" />
        <el-option
          label="表单"
          value="form" />
      </el-select>
    </el-form-item>
    <el-form-item label="排列方式">
      <el-select
        v-model="localData.children.arrangeType"
        placeholder="排列方式"
        clearable>
        <el-option
          label="横向"
          value="level" />
        <el-option
          label="竖向"
          value="vertical" />
      </el-select>
    </el-form-item>
    <el-form-item
      label="序号"
      v-if="localData.children.type == 'form'">
      <el-switch v-model="localData.children.index" />
    </el-form-item>
    <el-form-item label="添加按钮">
      <el-switch v-model="localData.children.addBtn" />
    </el-form-item>
    <el-form-item label="删除按钮">
      <el-switch v-model="localData.children.delBtn" />
    </el-form-item>
  </div>
</template>

<script>
export default {
  name: "ConfigDynamic",
  props: {
    data: {
      type: Object,
      default: () => {}
    }
  },
  data(){
    return {
      localData:{}
    }
  },
   watch: {
    data: {
      handler(newVal) {
        if (newVal) {
          this.localData = newVal
        }
      },
      deep: true,
      immediate: true
    },
    localData: {
      handler(newVal) {
        this.$emit('update:data', newVal)
      },
      deep: true
    }
  }
}
</script>
